﻿// (c)2010 David Schwarz (david.schwarz@live.com)
// This file is licensed under GNU GPL v2 license, see more at http://www.gnu.org/licenses/gpl-2.0.html
namespace Z2.Core
{

	#region Using

	using Microsoft.Xna.Framework;
	using System.Text;

	#endregion

	/// <summary>
	/// Obsahuje data o výsledku testování kolize
	/// </summary>
	public class IntersectionResult
	{

		#region Members

		private static IntersectionResult _none;

		private bool m_isCollision;
		private Rectangle m_rectangle;
		private IntersectionVerticalType m_verticalType;
		private IntersectionHorizontalType m_horizontalType;
		private ObjectBase m_with;

		#endregion

		#region Constructors

		/// <summary>
		/// Statický konstruktor
		/// </summary>
		static IntersectionResult()
		{
			_none = new IntersectionResult();
			_none.IsCollision = false;
		}

		/// <summary>
		/// Konstruktor
		/// </summary>
		public IntersectionResult()
		{
			this.m_isCollision = false;
		}

		#endregion

		#region Properties

		/// <summary>
		/// Vrací nebo nastavuje objekt, se kterým proběhla kolize
		/// </summary>
		public ObjectBase With
		{
			get
			{
				return this.m_with;
			}
			set
			{
				this.m_with = value;
			}
		}

		/// <summary>
		/// Vrací nebo nastavuje, ze kterého směru v ose X přišla kolize
		/// </summary>
		public IntersectionHorizontalType HorizontalType
		{
			get
			{
				return this.m_horizontalType;
			}
			set
			{
				this.m_horizontalType = value;
			}
		}

		/// <summary>
		/// Vrací nebo nastavuje, ze kterého směru v ose Y přišla kolize
		/// </summary>
		public IntersectionVerticalType VerticalType
		{
			get
			{
				return this.m_verticalType;
			}
			set
			{
				this.m_verticalType = value;
			}
		}

		/// <summary>
		/// Vrací kolizní RECT daného objektu/pole
		/// </summary>
		public Rectangle Rectangle
		{
			get
			{
				return this.m_rectangle;
			}
			set
			{
				this.m_rectangle = value;
			}
		}

		/// <summary>
		/// Vraíc nebo nastavuje, zda došlo ke kolizi
		/// </summary>
		public bool IsCollision
		{
			get
			{
				return this.m_isCollision;
			}
			set
			{
				this.m_isCollision = value;
			}
		}

		public Vector2 Correct
		{
			get;
			set;
		}

		/// <summary>
		/// Vrací objekt, který definuje žádnou kolizi
		/// </summary>
		public static IntersectionResult None
		{
			get
			{
				return _none;
			}
		}

		#endregion

#if DEBUG

        #region Override Methods

        public override string ToString()
		{
			StringBuilder builder = new StringBuilder();
			builder.AppendLine(IsCollision.ToString());
			return builder.ToString();
        }

        #endregion 

#endif

    }
}
